package com.cloud.controller;

import com.alibaba.fastjson.JSONObject;
import com.cloud.util.R;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import com.cloud.bean.Bill;
import com.cloud.service.BillService;

@Controller
@RequestMapping("/bill")
public class BillController {
	
	private static final Logger log = LoggerFactory.getLogger(BillController.class);
	
	@Autowired
	private BillService billService;
	
	@PostMapping("/list")
	public R showBillList(@RequestBody JSONObject params) {
		log.info("获取用户佣金列表: {}",params.getInteger("page"));
		return null;//billService.selectList(params);
	}
	
	@PostMapping("/detail")
	public R showBillDetail(String order) {
		log.info("获取佣金详情: {}",order);
		return billService.seletBillDetail(order);
	}
	
	@PostMapping("/flush")
	public String showBillFlushList(Integer page,Integer value) {
		log.info("刷新佣金页面: {}-{}",page,value);
		//billService.selectFlushList(page,value);
		return "bill::tableFlush";
	}
	
	@PostMapping("/pass")
	public R updateBillStatus(Bill bill) {
		log.info("审批通过: {}",bill);
		return billService.updateBillStatus(bill);
	}
	
	@PostMapping("/reason")
	public R updateReason(Bill bill,String reason) {
		log.info("审批不通过原因: {}-{}",bill,reason);
		bill.setReason(reason);
		return billService.updateReason(bill);
	}
}
